package com.ruoyi.system.service.impl;

import com.ruoyi.system.domain.TEmployee;
import com.ruoyi.system.mapper.TEmployeeDao;
import com.ruoyi.system.service.TEmployeeService;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import javax.annotation.Resource;
import java.util.List;

/**
 * (TEmployee)表服务实现类
 *
 * @author makejava
 * @since 2025-01-01 20:37:33
 */
@Service("tEmployeeService")
public class TEmployeeServiceImpl implements TEmployeeService {
    @Resource
    private TEmployeeDao tEmployeeDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public TEmployee queryById(String id) {
        return this.tEmployeeDao.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param tEmployee 筛选条件
     * @return 查询结果
     */
    @Override
    public List<TEmployee> queryByPage(TEmployee tEmployee) {
        return this.tEmployeeDao.queryAllByLimit(tEmployee);
    }

    /**
     * 新增数据
     *
     * @param tEmployee 实例对象
     * @return 实例对象
     */
    @Override
    public TEmployee insert(TEmployee tEmployee) {
        this.tEmployeeDao.insert(tEmployee);
        return tEmployee;
    }

    /**
     * 修改数据
     *
     * @param tEmployee 实例对象
     * @return 实例对象
     */
    @Override
    public TEmployee update(TEmployee tEmployee) {
        this.tEmployeeDao.update(tEmployee);
        return this.queryById(tEmployee.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String id) {
        return this.tEmployeeDao.deleteById(id) > 0;
    }
}
